package com.wl.week_01;

import java.util.*;

/**
 * 扑克牌案例
 * @author TaiZai
 * @data 2024/9/25 15:28
 */
public class Dome_3 {
    private static Scanner sc = new Scanner(System.in);
    // 扑克牌
    private static final List<Integer> cards = new ArrayList<>();
    private static final Map<Integer, String> cardMap = new HashMap<>();
    static {
        String[] suits = {"方块️", "梅花️", "红桃️", "黑桃️"};
        String[] ranks = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        int cnt = 0;
        for (String rank : ranks) {
            for (String suit : suits) {
                cardMap.put(cnt, suit + "-" + rank);
                cards.add(cnt++);
            }
        }
        cards.add(52);
        cards.add(53);
        cardMap.put(52, "小王");
        cardMap.put(53, "大王");
        // 打乱List中的元素
        Collections.shuffle(cards);
        Collections.shuffle(cards);
        Collections.shuffle(cards);
    }
    public static void main(String[] args) {
        List<Integer> player1 = new ArrayList<>();
        List<Integer> player2 = new ArrayList<>();
        List<Integer> player3 = new ArrayList<>();
        List<Integer> banker = new ArrayList<>();
        int index = 0, cnt = 0;
        for (Integer card : cards) {
            if(cnt++ < 51) {
                if (index % 3 == 0) player1.add(card);
                else if (index % 3 == 1) player2.add(card);
                else player3.add(card);
                index++;
            } else {
                banker.add(card);
            }
        }

        // 排序
        Collections.sort(player1);
        Collections.sort(player2);
        Collections.sort(player3);
        Collections.sort(banker);

        printCard(player1);
        printCard(player2);
        printCard(player3);
        printCard(banker);

    }

    public static void printCard(List<Integer> cards) {
        for (Integer card : cards) {
            System.out.print(cardMap.get(card) + "   ");
        }
        System.out.println();
    }
}
